/**
 * @version 2007-5-9
 * @author xalinx at gmail dot com
 */
package org.nanhill.commons.dbutil.dialect;

/**
 * @version 2007-5-9
 * @author xalinx at gmail dot com
 * 
 */
public class Mysql5Dialect extends Dialect {

	public String getLimitSql(String sql, boolean hasOffset) {
		return new StringBuffer(sql.length() + 20).append(sql).append(hasOffset ? " limit ?, ?" : " limit ?")
				.toString();
	}

	@Override
	public Object[] getLimitArguments(int start, int size, Object... args) {
		Object[] tmp = null;
		if (start == 0) {
			tmp = new Object[args.length + 1];
			tmp[tmp.length] = size;
		} else {
			tmp = new Object[args.length + 2];
			tmp[tmp.length - 1] = start;
			tmp[tmp.length] = size;
		}
		System.arraycopy(args, 0, tmp, 0, args.length);
		return tmp;
	}

}
